package br.com.esporte.apresentacao.componentes;

import org.apache.wicket.markup.ComponentTag;
import org.apache.wicket.markup.html.WebComponent;
import org.apache.wicket.model.IModel;

public class StaticImage extends WebComponent {

	private static final long serialVersionUID = 8841168818345226961L;

	private int height;
	private int width;

	public StaticImage(String id, IModel<String> model) {
		super(id, model);
	}

	public StaticImage(String id, IModel<String> model, int width, int height) {
		super(id, model);
		this.height = height;
		this.width = width;
	}

	@Override
	protected void onComponentTag(ComponentTag tag) {
		super.onComponentTag(tag);
		this.checkComponentTag(tag, "img");
		tag.put("src", this.getDefaultModelObjectAsString());
		if (width > 0) {
			tag.put("width", width);
		}
		if (height > 0) {
			tag.put("height", height);
		}

	}
}
